import {
	Loading
} from "element-ui";


import {
	API_ROOT,
	UPLOAD_ROOT
} from '@/config/env.js'


import {
	mapState
} from "vuex";
export default {
	data() {
		return {
			API_ROOT: process.env.NODE_ENV !== "production" ? API_ROOT :  location.origin + '/admin_service.php',

			mix_upload_action: UPLOAD_ROOT,

			//上传接口字段
			// upload_col_name: "file",
			upload_col_name: "img",

			//上传相关
			uploadAction: API_ROOT,

			// 文件上传处理
			upload_file_url: API_ROOT,
			upload_file_col: "file",
			//文件上传
		};
	},
	computed: {
		...mapState([
			//
			"vuex_user",
			"vuex_h5",
			"vuex_iframe_page_data",
			"userId",
			"token",
			"baseInfo",
			"defaultAvatar",
			"is_login",
			"is_open_oss_upload",
		]),

		//文件上传
		upload_file_data() {
			let token = localStorage.getItem("token");
			return {
				action: "upload_uploadFile",
				token: token,
			};
		},


	},
	created() {
		// console.log('mix_upload_action', this.mix_upload_action)
	},
	mounted() {},
	methods: {
		showLoading(is_hide) {
			if (is_hide) {
				this.loadingInstance = Loading.service({
					lock: true,
					text: "Loading...",
					spinner: "el-icon-loading",
					background: "rgba(255, 255, 255, .95)",
				});
			} else {
				this.loadingInstance = Loading.service({
					lock: true,
					text: "Loading...",
					spinner: "el-icon-loading",
					background: "rgba(0, 0, 0, 0.7)",
				});
			}
		},
		hideLoading() {
			if (this.loadingInstance) {
				this.loadingInstance.close();
			}
		},

		mix_logout() {
			this.$store.commit("clear_loginInfo");
			alertSucc("已退出登录");
			this.$router.push("/");
		},

		mix_get_token() {
			return localStorage.getItem('token')
		},


		toBack() {
			this.$router.back();
		},
		toLink(item) {
			if (item.url) {
				location.href = item.url;
			}
		},
		toRoute(route) {
			this.$router.push(route);
		},
	},
};